<!DOCTYPE html>
<html lang="zh-cn">
	<head>
	    <meta charset="utf-8">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	    <meta name="viewport" content="width=device-width, initial-scale=1">
	    <#include "/common/meta.ftl"/>
	    <#include "/common/form.ftl"/>
		<script>
		$(function(){
				$("#form").validate({
					rules: {
						roleName: {required:true,maxlength:228},
						roleOrder:{required:true,maxlength:10}
					},
					errorElement: "div",
					errorPlacement: function(error, element) {
						error.appendTo($(element).parent());
						$(element).parent().addClass("has-error");
						$(error).addClass("help-block alert-danger");
					},
					success: function(label) {
						$(label).parent().removeClass("has-error");
						$(label).remove();
					}
				})
			});
			function save(){
				if($("#form").valid()){
					$("#form").submit();
				}
			}
		</script>
	</head>
	<body style="padding:5px;">
		<div class="panel panel-primary">
			<div class="panel-heading" style="">
				<strong>
				<#if (roleID!'')!=''><i class="icon-pencil"></i> 编辑<#else><i class="icon-plus"></i> 添加</#if>角色
				</strong>
			</div>
			<div class="panel-body" style="padding:5px;padding-top:15px;">
			<form id="form" class="form-horizontal" role="form" method='post' action="./roleSave">
			<input type="hidden" name="roleID" value="${roleID?default('')}"/>
        		<div class="form-group">
          			<label class="col-md-1 col-md-offset-1 control-label required" >角色名称</label>
	          		<div class="col-sm-3">
	             		<input type='text'  name="roleName"  id='roleName' value='<#if formData?exists>${formData.roleName!''}</#if>' class='form-control' placeholder=''/>
	          		</div>
        		</div>
        		<div class="form-group">
          			<label class="col-md-1 col-md-offset-1 control-label required" >排序</label>
	          		<div class="col-md-3">
	             		<input type='text'  name="roleOrder" id='roleOrder' value='<#if formData?exists>${formData.roleOrder!''}<#else>10</#if>' class='form-control' placeholder=''/>
	          		</div>
        		</div>
        		<div class="form-group">
          			<label class="col-md-1 col-md-offset-1 control-label" >角色状态</label>
	          		<div class="col-sm-3">
	             		<select name='roleStatus' id='roleStatus' class='form-control'>
	             			<#assign o = 1/>
	             			<#if formData?exists>
	             			<#if formData.roleStatus?exists>
	             				<#assign o = formData.roleStatus/>
	             			</#if>
	             			</#if>
				            <option value="1"  <#if o==1>selected</#if>>正常</option>
							<option value="-1"  <#if o==-1>selected</#if>>停用</option>
			            </select>
	          		</div>
        		</div>
        		<div class="form-group">
          			<label class="col-md-1 col-md-offset-1 control-label" >备注</label>
	          		<div class="col-md-3">
	          			<textarea name="roleMemo"  id='roleMemo' class="form-control" rows="3" placeholder=""><#if formData?exists>${formData.roleMemo!''}</#if></textarea>
	          		</div>
        		</div>         		
        		<div class="form-group">
		          	<div class="col-md-offset-2 col-md-10">
		             	<button class="btn btn-primary" onclick="save();" type="button"><i class="icon icon-save"></i> 保存</button>
		             	<button class="btn" type="button" onclick="location.href='./role'"><i class="icon icon-reply"></i> 返回</button>
		          	</div>
		        </div>
        		</form>
		  	</div>
		</div>
	</body>
</html>